package com.hopes.bizz.risk.control.dto;

import com.hopes.bizz.risk.common.constant.enums.RiskModDictEnum;
import com.hopes.bizz.risk.control.entity.RiskUnitEntity;
import com.hopes.boss.admin.api.entity.SysDictItem;
import com.hopes.boss.admin.api.resolver.DictResolver;
import com.hopes.boss.common.entity.BaseLogicEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.beans.BeanUtils;

/**
 * @author daijie
 * @version 1.0
 * @date 2023/7/24 19:25
 * @Description:
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "风险分析单元DTO")
public class RiskUnitDTO extends BaseLogicEntity {

    private static final long serialVersionUID = 5383021492381155517L;

    public RiskUnitEntity toPO() {
        RiskUnitEntity entity = new RiskUnitEntity();
        BeanUtils.copyProperties(this, entity);
        SysDictItem itemByValue = DictResolver.getItemByValue(RiskModDictEnum.risk_object, riskObjectId.toString());
        String orgId = itemByValue.getExt2();
        entity.setOrgId(Long.valueOf(orgId));
        return entity;
    }

    private Long id;

    private Long riskObjectId;

    private String riskName;

    private String dept;

    private String principal;

    private Long orgId;
}
